<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

	class Keuangan_model extends CI_Model {

		function __construct()
		{
			parent::__construct();
			$this->CI = get_instance();
		}
		
		function get_transaksi_perbatch() {
			$this->db->select('PESERTA.ID_BATCH, BATCH.NAMA_BATCH');
			$this->db->select_sum('PESERTA.JUMLAH','TOTAL_PEMBAYARAN');
			$this->db->from('PESERTA');
			$this->db->join('BATCH','PESERTA.ID_BATCH = BATCH.ID_BATCH', 'left');
			$this->db->where("BATCH.STATUS > 0 ");
			$this->db->group_by('BATCH.ID_BATCH');
			$this->CI->flexigrid->build_query();
			
			$return['records'] = $this->db->get();
			
			$this->db->select('PESERTA.ID_BATCH, BATCH.NAMA_BATCH');
			$this->db->select_sum('PESERTA.JUMLAH','TOTAL_PEMBAYARAN');
			$this->db->from('PESERTA');
			$this->db->join('BATCH','PESERTA.ID_BATCH = BATCH.ID_BATCH', 'left');
			$this->db->where("BATCH.STATUS > 0 ");
			$this->db->group_by('BATCH.ID_BATCH');
			$this->CI->flexigrid->build_query(FALSE);
			$return['record_count'] = $this->db->count_all_results();
			
			return $return;
		}
		
	}
?>